diff -pruN old/caps.cpp new/caps.cpp
--- old/caps.cpp	2022-01-20 09:30:24.409886691 +0200
+++ new/caps.cpp	2022-01-20 09:39:10.669845265 +0200
@@ -1,4 +1,5 @@
 #include<iostream>
+#include <algorithm>
 #include<fstream>
 #include"BCFasta.h"
 #include"file_manip.h"
@@ -15,7 +16,7 @@
 #include<sys/time.h>
 #include<iomanip>
 #include <bits/stdc++.h> 
-
+#include <vector> 
 
 
 #include <Seq/SequenceApplicationTools.h>
@@ -69,6 +70,10 @@
 const gsl_rng_type * T;
 gsl_rng *r;
 
+// make sure filenames are sorted!
+// https://stackoverflow.com/a/34757557
+bool compareFunction (std::string a, std::string b) {return a<b;} 
+
 vector<double> totaltempnew;
 double alphathresh = 0;
 int main(int argc, char *argv[]){
@@ -189,6 +194,8 @@ int main(int argc, char *argv[]){
 
 	vector<string> files;
 	files = Folder_to_vector(mystring.c_str());
+	// make sure filenames are sorted!
+	std::sort(files.begin(),files.end(),compareFunction);
 
 	Fasta_vector file;
 	file.ref_num=0;
